#include<stdio.h>
#include<string.h>
#include<stdlib.h>

static int toTen(char s[], int radix)
{
	long sum=0;
	int len = strlen(s);
	long in = 1,n;
	int end = 0;
        int flag = 1;
	if(s[0] == '-')
	{
		flag = -1;
		end = 1;
	}
	int i=0;
	for(i=len-1; i>=end; i--)
	{
		if(s[i]>='A'&&s[i]<='F')
  		{
    			n=s[i]-'A'+10;
  		}
  		else if(s[i]>='a'&&s[i]<='f')
  		{
    			n=s[i]-'a'+10;
  		}
  		else
  		{
    			n=s[i]-'0';
  		}
		sum += n*in;
		in *= radix;
	}
	return sum*flag;
}

